{{ $pages := (where .Site.RegularPages "File.Dir" .File.Dir).ByWeight }}

  <div class="sidebar__wrapper-inner">
    <nav class="sidebar__container">
      <ul class="sidebar" id="mysidebar">
        {{- $overviewPage := index (where $pages ".File.TranslationBaseName" "in" (slice "readme" "README") ) 0 }}
        {{- if $overviewPage }}
          {{- template "moduleSidebarPage" (dict "ctx" $ "Page" $overviewPage ) }}
        {{- end }}
        {{- range $pages }}
          {{- if eq (strings.ToLower .File.TranslationBaseName) "readme" }}{{ continue }}{{ end }}
          {{- template "moduleSidebarPage" (dict "ctx" $ "Page" . ) }}
        {{- end }}
      </ul>
    </nav>
  </div>

{{/* --- moduleSidebarPage --- */}}
{{- define "moduleSidebarPage" }}

  {{- $pageTitle := "" }}
  {{- if in .ctx.Site.Data.helpers.knownPageNames .Page.File.TranslationBaseName }}
    {{- $pageTitle = T (printf "moduleLinkTitle%s" .Page.File.TranslationBaseName) }}
  {{- else if .Page.LinkTitle }}
    {{- $pageTitle = strings.TrimSpace .Page.LinkTitle }}
  {{- else if .Title }}
    {{- $pageTitle = strings.TrimSpace .Page.Title }}
  {{- end }}
  {{- if $pageTitle }}
       <li class="sidebar__item {{ if eq .ctx.Page .Page }}active{{ end }}">
          <a href="{{ if .Page.IsPage }}./{{ replaceRE "readme.html$" "" (path.Base .Page.RelPermalink) }}{{ else }}#{{ end }}">
          {{- $pageTitle -}}
          </a>
      </li>
  {{- end }}
{{- end }}
{{/* END --- moduleSidebarPage --- */}}
